import Vue from 'vue';
import Router from 'vue-router';

Vue.use(Router);
/*
*用户模块---start
* @ author &jin.tao
*/
const home = () => import(/* webpackChunkName: "home" */'@/views/home/home.vue')//首页
const login = () => import(/* webpackChunkName: "login" */'@/views/login/login.vue')//登录


const routes = [
  {
    path: '*',
    redirect: '/home'
  },
  {
    name: 'home',
    component: home,
    meta: {
      title: '首页',
      keepAlive: true
    }
  },

  {
    path: '/login',
    name: 'login',
    component: login,
    meta: {
      title: '登录',
      keepAlive: false
    }
  },
];

// add route path
routes.forEach(route => {
  route.path = route.path || '/' + (route.name || '');
});

const router = new Router({
  // mode: 'history',
  linkActiveClass: 'act',
  scrollBehavior: () => ({ y: 0 }),
  routes: routes
});

const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

export {
  router
};
